"use strict";

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = (app) => {
	const {router, controller} = app;
	// jwt
	let jwt = app.middleware.jwt({app});
	// hi,egg
	router.get("/", controller.home.index);

	// 邮箱验证码
	router.get("/user/sendcode", controller.user.sendcode);
	// 图片验证码
	router.get("/user/captcha", controller.user.captcha);
	// 注册
	router.post("/user/register", controller.user.register);
	// 登录
	router.post("/user/login", controller.user.login);
	// 获取用户信息
	router.get("/user/detail", jwt, controller.user.detail);
	// 判断用户是否被关注
	router.get("/user/isFollow/:id", jwt, controller.user.isFollow);
	// 关注某个用户
	router.put("/user/follow/:id", jwt, controller.user.follow);
	// 取消关注某个用户
	router.delete("/user/follow/:id", jwt, controller.user.cancelFollow);
	// 获取用户关注的人
	router.get("/user/:id/following", jwt, controller.user.following);
	// 获取用户的粉丝
	router.get("/user/:id/follows", jwt, controller.user.follows);
	// 用户点击喜欢某篇文章
	router.put("/user/likeArticle/:id", jwt, controller.user.likeArticle);
	// 用户点击取消喜欢某篇文章
	router.delete("/user/likeArticle/:id", jwt, controller.user.cancellikeArticle);
	// 获取某个用户喜欢的文章集合
	router.get("/user/:id/likeArticles", controller.user.getUserLikeArticles);
	// 根据用户ID 获取用户信息
	router.get("/user/:id", controller.user.getUserInfoById);


	// 获取文章列表
	router.get("/article", controller.article.getArticleList);
	// 文章详情
	router.get("/article/:id", controller.article.getArticleById);
	// 发布文章
	router.post("/article/create", jwt, controller.article.create);

	// 获取文章分类
	router.get("/categories", controller.category.categories);

	// 处理上传图片
	router.post("/upload", controller.upload.index);

	// 创建一条评论
	router.post("/comment", controller.comment.create);
	// 获取评论列表
	router.get("/comments", controller.comment.commentsList);
	//对某条评论 进行回复
	router.post("/reply", controller.comment.reply);

	// 获取七牛token
	router.get('/getQiniuToken', jwt, controller.article.getQiniuToken);
};
